package de.hwrberlin.remo.diagram.custom.util;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.graphics.Image;

import de.hwrberlin.remo.diagram.part.RemoDiagramEditorPlugin;


public class ImageUtil {
	
	private static ImageRegistry imageRegistry;
	private static final String[] IMAGES = new String[] {
		Images.TRUE_IMAGE,
		Images.FALSE_IMAGE,
		Images.UNKNOWN_IMAGE,
		Images.NOT_IMAGE,
		
		Images.FIRST_IMAGE,
		Images.PREVIOUS_IMAGE,
		Images.NEXT_IMAGE,
		Images.LAST_IMAGE
	};
	
	private static ImageRegistry getImageRegistry() {
		
		if (imageRegistry == null) {
			imageRegistry = new ImageRegistry();
			
			for(String image : IMAGES) {
				ImageDescriptor imageDescriptor = RemoDiagramEditorPlugin.findImageDescriptor(image);
				imageRegistry.put(image, imageDescriptor);
			}
		}
		
		return imageRegistry;
	}
	
	public static Image getImage(String name) {
		return getImageRegistry().get(name);
	}
}
